﻿using CATL.PrintMarkingServer.DAL.DBConnectionHelper;
using Microsoft.AspNetCore.Mvc;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

namespace CenterControllerServer.WebApi.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class SqlServerClientController
    {
        private readonly SqlServerClient _client;

        public SqlServerClientController(SqlServerClient client)
        {
            _client = client;
        }

        [HttpGet]
        public async Task<List<string>> Get(int index)
        {
            return await _client.ReadAsStringAsync($"SELECT * FROM UserInfo WHERE name='lanxiaofang{index + 1}'");
        }

        [HttpPut]
        public void Put()
        {
            for (int i = 0; i < 150000; i++)
            {
                var write = _client.WriteAsync($"INSERT INTO UserInfo (name,age,phone) values ('lanxiaofang{i + 1}',25,'13604461032');");
                write.Wait();
                Console.WriteLine(i);
            }
        }

    }
}
